Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/i18n

Package Overview
Dependencies
Maintainers
0
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/i18n

WordPress internationalization (i18n) library.

  • 5.12.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
129K
decreased by-10.9%
Maintainers
0
Weekly downloads
 
Created

What is @wordpress/i18n?

@wordpress/i18n is a package designed to provide internationalization (i18n) support for WordPress projects. It allows developers to easily translate strings and manage localization in their WordPress plugins and themes.

What are @wordpress/i18n's main functionalities?

Translating Strings

The `__` function is used to translate a string. The first argument is the string to be translated, and the second argument is the text domain.

const { __ } = require('@wordpress/i18n');
const translatedString = __('Hello, world!', 'text-domain');
console.log(translatedString);

Translating with Context

The `_x` function is used to translate a string with context. The first argument is the string to be translated, the second argument is the context, and the third argument is the text domain.

const { _x } = require('@wordpress/i18n');
const translatedString = _x('Post', 'noun', 'text-domain');
console.log(translatedString);

Plural Translations

The `_n` function is used for plural translations. The first argument is the singular form, the second argument is the plural form, the third argument is the number, and the fourth argument is the text domain.

const { _n } = require('@wordpress/i18n');
const translatedString = _n('%d post', '%d posts', 2, 'text-domain');
console.log(translatedString);

Translating with Context and Plural

The `_nx` function is used for plural translations with context. The first argument is the singular form, the second argument is the plural form, the third argument is the number, the fourth argument is the context, and the fifth argument is the text domain.

const { _nx } = require('@wordpress/i18n');
const translatedString = _nx('%d comment', '%d comments', 2, 'noun', 'text-domain');
console.log(translatedString);

Other packages similar to @wordpress/i18n

Keywords

FAQs

Package last updated on 16 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc